package com.worldcup.service.impl;

import com.worldcup.dao.TravelSearchLogMapper;
import com.worldcup.service.ITravelSearchLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @author duwan.zq
 * @date 2018/12/07
 */
@Service
public class TravelSearchLogService implements ITravelSearchLogService{

    @Autowired
    private TravelSearchLogMapper travelSearchLogMapper;

    @Override
    public Map<String, Integer> statisticsSearchCount() {
        Map<String, Integer> result = new HashMap<>(8);
        result.put("城市", countNotNullColumn("citys"));
        result.put("比赛", countNotNullColumn("`match`"));
        result.put("日期", countNotNullColumn("date"));
        result.put("年龄", countNotNullColumn("age"));
        result.put("性别", countNotNullColumn("gender"));
        return result;
    }

    private Integer countNotNullColumn(String columnName) {
        return travelSearchLogMapper.countNotNullColumn(columnName);
    }
}
